package com.lanxigua.ui;

import android.content.Intent;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.Window;
import android.widget.Toast;

import com.lanxigua.ui.master.About;
import com.lanxigua.utils.Tooltips;

public abstract class Base extends android.app.Activity {
	
	public final Tooltips Tooltips = new Tooltips(this);
	/**
	 * Hide application title bar
	 */
	public void hideTitle() {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(0, 1, 1, "关于");
		menu.add(0, 2, 2, "香蕉2");
		menu.add(0, 3, 3, "苹果3");
		menu.add(0, 4, 4, "香蕉4");
		menu.add(0, 5, 5, "苹果5");
		menu.add(0, 6, 6, "香蕉6");
		menu.add(0, 7, 7, "苹果7");
		menu.add(0, 8, 8, "香蕉8");

		SubMenu subMenu = menu.addSubMenu(1, 100, 100, "桃子");
		subMenu.add(2, 101, 101, "大桃子");
		subMenu.add(2, 102, 102, "小桃子");
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId() == 1) {
			if (item.getOrder() == 1)
			{
				Intent in = new Intent(Base.this, About.class);
				Base.this.startActivity(in);
			}
			Toast t = Toast.makeText(this, "你选的是苹果", Toast.LENGTH_SHORT);
			t.show();
		} else if (item.getItemId() == 2) {
			Toast t = Toast.makeText(this, "你选的是香蕉", Toast.LENGTH_SHORT);
			t.show();
		} else {
			Toast t = Toast.makeText(this, "你选的" + item.getItemId(),
					Toast.LENGTH_SHORT);
			t.show();
		}
		return true;
	}
	@Override  
	public boolean onKeyDown(int keyCode, KeyEvent event) {  
//		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {  
//			return true;
//		}
		return super.onKeyDown(keyCode, event);
	}
}